package com.tax.domain.service;

import com.tax.domain.constant.businessconstant.BusinessConstant;
import com.tax.domain.dto.machine.PerformSubmitContext;
import com.tax.domain.dto.req.PerformSubmitReq;
import com.tax.domain.factory.BizScenarioFactory;
import com.tax.domain.factory.PerformSubmitFactory;
import com.tax.domain.service.perform.PerformSubmitI;
import com.tax.infrastructure.extension.BizScenario;
import com.tax.infrastructure.extension.ExtensionExecutor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class PerformOrderSubmitService {
    @Autowired
    private ExtensionExecutor extensionExecutor;
    public void performCreate(PerformSubmitReq req) {
        //获取使用场景
        BizScenario bizScenario = BizScenarioFactory.create(BusinessConstant.BIZ_UDBUS
                , BusinessConstant.UseCase.PERFORM_CREATE, req.getOrderType());
        //创建上下文对象
        PerformSubmitContext context = PerformSubmitFactory.performSubmitContext(bizScenario, req);
        //根据使用场景获取实现类
        PerformSubmitI performSubmitI = extensionExecutor.locateComponent(PerformSubmitI.class, bizScenario);
        //执行具体逻辑
        performSubmitI.execute(context);
    }
}
